﻿var dictedit = {
    formDefine: {
        labelWidth: 85, inputWidth: 195, space: 10, labelAlign: 'right',
        fields: [

                    { display: lang.type_name + "：", name: "DICTTYPE_NAME", type: "text", newline: true, width: 260, serviceDataName: 'DICTTYPE_NAME' },
                    { display: lang.type_ID_dig + "：", name: "DICTTYPE_ID", type: "text", newline: true, serviceDataName: 'DICTTYPE_ID' },
                    { display: "", name: "", type: "lable", newline: true, serviceDataName: '' },
                    { display: lang.save, name: "search", type: "button", newline: true, nlstyle: "text-align:center;margin-top:10px;", width: 280, click: function () { dictedit.form.submit(); } },
                    { display: lang.close, name: "close", type: "button", width: 280, click: function () {
                        parent.$.closePage();
                    }
                    }
                ],
        submitUrl: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
        submitUrlType: "EditDictType",
        submitCheck: function (params) {
            if (!params["DICTTYPE_ID"] || params["DICTTYPE_ID"] == "") {
                return lang.type_ID_can_not_be_empty;
            }
            if (!params["DICTTYPE_NAME"] || params["DICTTYPE_NAME"] == "") {
                return lang.type_name_can_not_be_empty;
            }

            return "";
        },
        submitParams: function (params) {
            if ($.getPara('dicttypeid') && $.getPara('dicttypeid') != '') {
                params.action = 1;
                params.OldDICTTYPE_ID = $.getPara('dicttypeid');
            } else { params.action = 2; }
            return params;
        },
        submitSuccess: function () {
            if ($.getPara('dicttypeid') && $.getPara('dicttypeid') != '') {
                $.alert(lang.type_modified_success, null, function () { parent.dictlist.search(); parent.$.closePage(); });
            } else {
                $.alert(lang.add_new_type_success, null, function () { parent.dictlist.search(); parent.$.closePage(); });
            }
        }
    },
    init: function () {
       
        if ($.getPara('dicttypeid') && $.getPara('dicttypeid') != '') {
            this.formDefine.url = App_Config.TadongUrl + "/AjaxMappingHandler.aspx";
            this.formDefine.urlType = "GetDictType";
            this.formDefine.params = function () { return $.getPara('dicttypeid'); };
        }
        jsPageRender(this);
    }
};